<?php
/**
 * Created by PhpStorm.
 * Author: Shadow
 * Date: 2022/1/14
 * Time: 3:51 下午
 * description: Category.php
 */

namespace app\home\business;


class Category
{
    /**
     * 查询分类列表
     * @return array
     */
    public static function getList(){
        $data = \app\common\model\Category::field('id,cate_name,pid,level')->select()->toArray();
        $handle_data =  recursion_tree($data); # 树形结构
        $handle_data = recursion_handle_data($data);# 父子级结构
        return $handle_data;
    }

    /**
     * 获取分类详情
     * @param $id
     * @return array
     * @throws \think\Exception
     */
    public static function info($id){
        return \app\common\model\Category::find($id)->toArray();
    }
}